package org.linlinjava.litemall.db.domain;

import lombok.Data;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

/**
 * 定时任务：订单佣金
 */
@Data
public class TaskOrderCommissionExample {

    protected String orderByClause;
    protected boolean distinct;
    protected List<TaskOrderCommissionExample.Criteria> oredCriteria;

    public TaskOrderCommissionExample.Criteria or() {
        TaskOrderCommissionExample.Criteria criteria = createCriteriaInternal();
        oredCriteria.add(criteria);
        return criteria;
    }

    public TaskOrderCommissionExample orderBy(String orderByClause) {
        this.setOrderByClause(orderByClause);
        return this;
    }

    public TaskOrderCommissionExample orderBy(String... orderByClauses) {
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < orderByClauses.length; i++) {
            sb.append(orderByClauses[i]);
            if (i < orderByClauses.length - 1) {
                sb.append(" , ");
            }
        }
        this.setOrderByClause(sb.toString());
        return this;
    }

    public static class Criteria extends TaskOrderCommissionExample.GeneratedCriteria {

        private TaskOrderCommissionExample example;

        protected Criteria(TaskOrderCommissionExample example) {
            super();
            this.example = example;
        }

        public TaskOrderCommissionExample example() {
            return this.example;
        }

        public TaskOrderCommissionExample.Criteria andIf(boolean ifAdd, TaskOrderCommissionExample.Criteria.ICriteriaAdd add) {
            if (ifAdd) {
                add.add(this);
            }
            return this;
        }

        public interface ICriteriaAdd {
            TaskOrderCommissionExample.Criteria add(TaskOrderCommissionExample.Criteria add);
        }
    }

    public TaskOrderCommissionExample.Criteria createCriteria() {
        TaskOrderCommissionExample.Criteria criteria = createCriteriaInternal();
        if (oredCriteria.size() == 0) {
            oredCriteria.add(criteria);
        }
        return criteria;
    }

    protected TaskOrderCommissionExample.Criteria createCriteriaInternal() {
        TaskOrderCommissionExample.Criteria criteria = new TaskOrderCommissionExample.Criteria(this);
        return criteria;
    }

    public void clear() {
        oredCriteria.clear();
        orderByClause = null;
        distinct = false;
    }

    public static TaskOrderCommissionExample.Criteria newAndCreateCriteria() {
        TaskOrderCommissionExample example = new TaskOrderCommissionExample();
        return example.createCriteria();
    }


    public static class Criterion {
        private String condition;

        private Object value;

        private Object secondValue;

        private boolean noValue;

        private boolean singleValue;

        private boolean betweenValue;

        private boolean listValue;

        private String typeHandler;

        public String getCondition() {
            return condition;
        }

        public Object getValue() {
            return value;
        }

        public Object getSecondValue() {
            return secondValue;
        }

        public boolean isNoValue() {
            return noValue;
        }

        public boolean isSingleValue() {
            return singleValue;
        }

        public boolean isBetweenValue() {
            return betweenValue;
        }

        public boolean isListValue() {
            return listValue;
        }

        public String getTypeHandler() {
            return typeHandler;
        }

        protected Criterion(String condition) {
            super();
            this.condition = condition;
            this.typeHandler = null;
            this.noValue = true;
        }

        protected Criterion(String condition, Object value, String typeHandler) {
            super();
            this.condition = condition;
            this.value = value;
            this.typeHandler = typeHandler;
            if (value instanceof List<?>) {
                this.listValue = true;
            } else {
                this.singleValue = true;
            }
        }

        protected Criterion(String condition, Object value) {
            this(condition, value, null);
        }

        protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
            super();
            this.condition = condition;
            this.value = value;
            this.secondValue = secondValue;
            this.typeHandler = typeHandler;
            this.betweenValue = true;
        }

        protected Criterion(String condition, Object value, Object secondValue) {
            this(condition, value, secondValue, null);
        }
    }

    protected abstract static class GeneratedCriteria {
        protected List<TaskOrderCommissionExample.Criterion> criteria;

        protected GeneratedCriteria() {
            super();
            criteria = new ArrayList<TaskOrderCommissionExample.Criterion>();
        }

        public boolean isValid() {
            return criteria.size() > 0;
        }

        public List<TaskOrderCommissionExample.Criterion> getAllCriteria() {
            return criteria;
        }

        public List<TaskOrderCommissionExample.Criterion> getCriteria() {
            return criteria;
        }

        protected void addCriterion(String condition) {
            if (condition == null) {
                throw new RuntimeException("Value for condition cannot be null");
            }
            criteria.add(new TaskOrderCommissionExample.Criterion(condition));
        }

        protected void addCriterion(String condition, Object value, String property) {
            if (value == null) {
                throw new RuntimeException("Value for " + property + " cannot be null");
            }
            criteria.add(new TaskOrderCommissionExample.Criterion(condition, value));
        }

        protected void addCriterion(String condition, Object value1, Object value2, String property) {
            if (value1 == null || value2 == null) {
                throw new RuntimeException("Between values for " + property + " cannot be null");
            }
            criteria.add(new TaskOrderCommissionExample.Criterion(condition, value1, value2));
        }

        public TaskOrderCommissionExample.Criteria andIdEqualTo(Integer value) {
            addCriterion("id =", value, "id");
            return (TaskOrderCommissionExample.Criteria) this;
        }

        public TaskOrderCommissionExample.Criteria andUserIdEqualTo(Integer value) {
            addCriterion("user_id =", value, "userId");
            return (TaskOrderCommissionExample.Criteria) this;
        }

        public TaskOrderCommissionExample.Criteria andCreatedTimeBetween(LocalDateTime value1, LocalDateTime value2) {
            addCriterion("created_time between", value1, value2, "createdTime");
            return (TaskOrderCommissionExample.Criteria) this;
        }
        public TaskOrderCommissionExample.Criteria andCreatedTimeGreaterThanOrEqualTo(LocalDateTime value) {
            addCriterion("created_time >=", value, "createdTime");
            return (TaskOrderCommissionExample.Criteria) this;
        }
        public TaskOrderCommissionExample.Criteria andCreatedTimeLessThanOrEqualTo(LocalDateTime value) {
            addCriterion("created_time <=", value, "createdTime");
            return (TaskOrderCommissionExample.Criteria) this;
        }
    }
}
